package q02_AddTwoNums;

import java.util.Scanner;

import static CommonClass.Common.ListNode;
public class Solution {


    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s = input.nextLine();
        System.out.println(s);
        // System.out.println("两数相加");
    }

    public static ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        ListNode head = null, tail = null;
        int carry = 0;
        while (l1 != null || l2 != null) {
            int n1 = l1 != null ? l1.val : 0;
            int n2 = l2 != null ? l2.val : 0;
            int sum = n1 + n2 + carry;
            if (head == null) {
                head = new ListNode(sum % 10);
                tail = head;
                //head = tail = new CommonClass.ListNode(sum % 10);
                //该问题涉及到Java的指针问题
                /*
                当同时给head和tail指向一个new ListNode后
                每次给tail.next赋值，然后使
                tail = tail.next;
                此时tail指向tail后面的那个节点，而head则仍然保留之前的各个next节点
                 */

            } else {
                tail.next = new ListNode(sum % 10);
                tail = tail.next;
            }
            carry = sum / 10;
            if (l1 != null) {
                l1 = l1.next;
            }
            if (l2 != null) {
                l2 = l2.next;
            }
        }

        if (carry > 0) {
            tail.next = new ListNode(carry);
        }

        return head;
    }
}
